package com.fare.taluo.core.domain.config.channel;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Table;

import com.dayatang.domain.InstanceFactory;
import com.fare.taluo.base.ddd.domain.baseentity.BaseEntity;

@javax.persistence.Entity
@Table(name = "FDC_AGENT")
@SuppressWarnings("serial")
public class AgentEntity extends BaseEntity {

	/**
	 * 代理商名称，如：兄弟旅行网
	 */
	@Column(name = "AGENT_NAME")
	private String name;
	/**
	 * 代理商公司名称，如：北京天原兄弟旅行社有限公司
	 */
	@Column(name = "COMPANY_NAME")
	private String cname;
	/**
	 * 代理商公司地址，如：北京市西城区西直门南
	 */
	@Column(name = "ADDRESS")
	private String address;
	/**
	 * 代理商公司网址，如：xdx.trade.qunar.com
	 */
	@Column(name = "WEB")
	private String web;
	/**
	 * 代理商公司电话，如：020-36172911
	 */
	@Column(name = "PHONE")
	private String phone;
	/**
	 * 机票原价
	 */
	@Column(name = "ORIGINAL_PRICE")
	private String originalPrice;
	/**
	 * 机票优惠价
	 */
	@Column(name = "PRICE")
	private String price;

	/**
	 * 代理商类型 0表示直营（如：深航自己的航班） 1表示承运（如：深航飞国际的航班） 2表示普通代理（如：携程艺龙淘宝卖票）
	 */
	@Column(name = "TYPE")
	private Integer type;

	@Column(name = "AGENT_CODE")
	private Integer agentCode;

	@Column(name = "CHANNEL")
	private String channel;

	@Column(name = "CHANNEL_NAME")
	private String channelName;

	private static AgentEntityReposity agentEntityReposity;

	public static AgentEntityReposity getAgentEntityReposity() {
		if (agentEntityReposity == null) {
			agentEntityReposity = InstanceFactory
					.getInstance(AgentEntityReposity.class);
		}
		return agentEntityReposity;
	}

	public List<AgentEntity> findAgentEntityByAgentCode(String agentCode) {
		return getAgentEntityReposity().findAgentEntityByAgentCode(agentCode);
	}
	
	public boolean entityExist(String agentCode,String channel){
		return getAgentEntityReposity().entityExist(agentCode,channel);
	}
	
	public List<AgentEntity> findAll() {
		return getAgentEntityReposity().findAll();
	}

	public void saveOrUpdate(AgentEntity entity) {
		/* getAgentEntityReposity().saveOrUpdate(entity); */
		// getRepository().save(entity);
		getAgentEntityReposity().saveOrUpdate(entity);
	}
	
	public void remove(){
		getAgentEntityReposity().remove(this);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCname() {
		return cname;
	}

	public void setCname(String cname) {
		this.cname = cname;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getWeb() {
		return web;
	}

	public void setWeb(String web) {
		this.web = web;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getOriginalPrice() {
		return originalPrice;
	}

	public void setOriginalPrice(String originalPrice) {
		this.originalPrice = originalPrice;
	}

	public String getPrice() {
		return price;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public Integer getAgentCode() {
		return agentCode;
	}

	public void setAgentCode(Integer agentCode) {
		this.agentCode = agentCode;
	}

	public String getChannel() {
		return channel;
	}

	public void setChannel(String channel) {
		this.channel = channel;
	}

	public String getChannelName() {
		return channelName;
	}

	public void setChannelName(String channelName) {
		this.channelName = channelName;
	}

}
